//
//  LewPopupViewAnimationActionSheet.m
//  shaohuo
//
//  Created by my on 16/4/6.
//  Copyright © 2016年 lchenc3. All rights reserved.
//

#import "LewPopupViewAnimationActionSheet.h"

@implementation LewPopupViewAnimationActionSheet

- (void)showView:(UIView *)popupView overlayView:(UIView *)overlayView {
    
    CGSize sourceSize = overlayView.bounds.size;
    CGSize popupSize = popupView.bounds.size;
    
    overlayView.alpha = 0.0f;
    CGRect popupStartRect = CGRectMake(0, sourceSize.height+popupSize.height, sourceSize.width, popupSize.height);
    popupView.frame = popupStartRect;
    
    CGRect popupFinalRect = CGRectMake(0, sourceSize.height-popupSize.height, sourceSize.width, popupSize.height);
    
    [UIView animateWithDuration:0.35 delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{
        popupView.frame = popupFinalRect;
        overlayView.alpha = 1.0f;
    } completion:^(BOOL finished) {
        
    }];
    
}

- (void)dismissView:(UIView *)popupView overlayView:(UIView *)overlayView completion:(void (^)(void))completion {
    
    CGSize sourceSize = overlayView.bounds.size;
    CGSize popupSize = popupView.bounds.size;
    
    CGRect popupFinalRect = CGRectMake(0, sourceSize.height+popupSize.height, sourceSize.width, popupSize.height);
    
    [UIView animateWithDuration:0.35 delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{
        popupView.frame = popupFinalRect;
        overlayView.alpha = 1.0f;
    } completion:^(BOOL finished) {
        completion();
    }];
}

@end
